package com.tsd.core.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;

/**
 * @Description: spring配置类，扫描的包，与读取的资源文件，创建数据源
 * 通过该注解来表明该类是一个Spring的配置，相当于一个xml文件
 * @Author Luoyc
 * @Date 2019/2/18 10:07
 * @Modefied By:
 */
@Configuration
@ComponentScan(basePackages = "com.tsd",
        includeFilters = {@ComponentScan.Filter(type = FilterType.ANNOTATION, value = Controller.class)},
        excludeFilters = {@ComponentScan.Filter(type = FilterType.ANNOTATION, value = Service.class)}) // 配置扫描包
public class SpringConfig {

    /**
     * 多部分文件上传,总量最大500MB，单文件最大是100MB
     *
     * @return
     */
    @Bean
    public CommonsMultipartResolver multipartResolver() {
        CommonsMultipartResolver resolver = new CommonsMultipartResolver();
//		resolver.setMaxUploadSize(524288000);
//		resolver.setMaxUploadSizePerFile(104857600);
//		resolver.setMaxInMemorySize(4096);
        resolver.setDefaultEncoding("UTF-8");
        return resolver;
    }
}
